//--------------------------------------------------------------
//
// Qizhi Zhang 
// ezhung@gmail.com
// http://www.moorwind.com
//
//--------------------------------------------------------------
package reader.services
{
	import flash.events.EventDispatcher;
	import flash.events.IOErrorEvent;
	
	import mx.core.UIComponent;
	
	import reader.ApplicationFacade;
	import reader.core.ReaderError;
	import reader.model.IServiceProxy;
	import reader.model.vo.ServiceVO;
	
	public class AbstractService extends EventDispatcher
	{
		protected const SERVICE_SECRET:String = "d6a58ea19ecf63bd29d3e4fa4c737ffa";
		
		protected var service:ServiceVO;
		protected var proxy:IServiceProxy;
		protected var parent:UIComponent;
		
		public function AbstractService(service:ServiceVO, proxy:IServiceProxy, parent:UIComponent = null)
		{
			this.service = service;
			this.proxy = proxy;
			this.parent = parent;
		}
		
		protected function initialize():void
		{
			throw new ReaderError(ReaderError.ABSTRACT_ERROR);
		}
		
		protected function onServiceError_handler(e:IOErrorEvent):void
		{
			proxy.sendNotification(ApplicationFacade.SERVICE_ERROR, null, service.name);
		}
	}
}